package com.xc.service.impl;

import com.ag.exception.CodeException;
import com.ag.exception.SysTipsException;
import com.ag.utils.BigDecimals;
import com.ag.utils.NumberUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.xc.common.ServerResponse;
import com.xc.dao.*;
import com.xc.pojo.*;
import com.xc.service.*;
import com.xc.utils.DateTimeUtil;
import com.xc.utils.KeyUtils;
import com.xc.utils.stock.BuyAndSellUtils;
import com.xc.utils.stock.GeneratePosition;
import com.xc.utils.stock.GetStayDays;
import com.xc.utils.stock.sina.SinaStockApi;
import com.xc.vo.agent.AgentIncomeVO;
import com.xc.vo.position.*;
import com.xc.vo.stock.StockAllotmentVO;
import com.xc.vo.stock.StockBlockTradeVO;
import com.xc.vo.stock.StockListVO;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Service("iUserPositionHistorySService")
public class UserPositionHistoryServiceImpl implements IUserPositionHistoryService {

    private static final Logger log = LoggerFactory.getLogger(UserPositionHistoryServiceImpl.class);

    @Autowired
    UserPositionMapper userPositionMapper;

    @Transactional
    public ServerResponse opNewStockHistory(  int id) {
        List<UserPosition> userPositionList = userPositionMapper.findPositionByUserId(id);
        userPositionList.forEach(userPosition -> {
            userPositionMapper.updatePositionHistory(userPosition.getId());
        });
        return ServerResponse.createBySuccess(userPositionList);
    }
}

